package cn.fl.spdealer.service.impl;

import java.util.List;

import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.logger.eum.LogOperEnum;
import fl.constant.facade.framework.constant.BusinessIdConstant;
import fl.spl.facade.framework.constant.SplSystemConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.spdealer.service.ISplExecCaseinfoService;
import cn.fl.spdealer.transform.SplExecCaseinfoVOTransform;
import cn.fl.spdealer.vo.SplExecCaseinfoVO;
import sp.dealer.facade.dealer.api.ISplExecCaseinfoApiService;
import sp.dealer.facade.dealer.condition.SplExecCaseinfoQC;
import sp.dealer.facade.dealer.dto.SplExecCaseinfoDTO;

/**
 * @Description: 行政处罚历史信息 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class SplExecCaseinfoServiceImpl implements ISplExecCaseinfoService {

	/**
	 * TODO 自定义 API 暴露服务
	 */
	@Autowired
	private ISplExecCaseinfoApiService splExecCaseinfoApiService;

	@Override
	public SplExecCaseinfoVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.newWebLogger("主键参数为空").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
			return null;
		}
		//TODO 业务逻辑
		SplExecCaseinfoDTO dto = this.splExecCaseinfoApiService.selectById(id);
		return SplExecCaseinfoVOTransform.toVO(dto);
	}

	@Override
	public Long add(SplExecCaseinfoVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.newWebLogger("新增对象不能为空").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
			return null;
		}
		return this.splExecCaseinfoApiService.add(SplExecCaseinfoVOTransform.toDTO(entity));
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.newWebLogger("删除主键参数不能为空").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
			return false;
		}
		return this.splExecCaseinfoApiService.removeById(id);
	}
	
	/**
     * 删除
     * @param ids
     * @return
     */
	@Override
    public boolean removeByIds(List<Long> ids)throws BaseException{
    	if(CollectionUtils.isEmpty(ids)){
			return false;
		};
		return false;
    }

	@Override
	public boolean modify(SplExecCaseinfoVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.newWebLogger("修改对象参数不能为空").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
			return false;
		}
		return this.splExecCaseinfoApiService.modify(SplExecCaseinfoVOTransform.toDTO(entity));
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page){
			page = new Pager();
		}
		return this.splExecCaseinfoApiService.searchListPage(page);
	}

	@Override
	public List<SplExecCaseinfoVO> searchList(SplExecCaseinfoQC condition) throws BaseException {
		// TODO Auto-generated method stub
		if(condition == null){
			return null ;
		}
		List<SplExecCaseinfoDTO> list = this.splExecCaseinfoApiService.searchList(condition);
		return SplExecCaseinfoVOTransform.toVOList(list);
	}

	@Override
	public int batchAdd(List<SplExecCaseinfoVO> list) throws BaseException {
		// TODO Auto-generated method stub
		if(CollectionUtils.isEmpty(list)){
			return 0;
		}
		int i = this.splExecCaseinfoApiService.batchAddSplExecCaseinfoDTO(SplExecCaseinfoVOTransform.toDTOList(list));
		return i;
	}
}
